﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PacCraft
{
    class Line
    {
        VertexPositionColor[] vertices;
        public Color theColor;
        private Vector3 from;
        private Vector3 to;

        public Line(Vector3 _from, Vector3 _to, Color color)
        {
            vertices = new VertexPositionColor[2];
            vertices[0] = new VertexPositionColor(_from, color);
            vertices[1] = new VertexPositionColor(_to, color);
            theColor = color;
            from = _from;
            to = _to;
        }

        public void setXY(Vector3 from, Vector3 to)
        {
            vertices[0] = new VertexPositionColor(from, theColor);
            vertices[1] = new VertexPositionColor(to, theColor);
        }

        public void Draw(GraphicsDeviceManager graphics, BasicEffect basicEffect)
        {
            basicEffect.CurrentTechnique.Passes[0].Apply();
            graphics.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, 1);
        }

        public Ray getRay()
        {
            return new Ray(from, to - from);
        }
    }
}
